﻿CREATE PROCEDURE [steve].[spSteve_InsertUrlRewrite]
	@UrlRewriteId uniqueidentifier,
	@SiteName varchar(50),
	@SystemName varchar(50),
	@ExternalId varchar(50),
	@Url varchar(800),
	@StartDate datetime2(7),
	@EndDate datetime2(7),
	@IsSecure bit,
	@RewriteOrder int,
	@IgnoreQueryString bit,
	@PassQueryString bit,
	@SiteUrlId uniqueidentifier,
	@RevisionDate datetime2(7),
	@RevisionMembershipId uniqueidentifier,
	@RevisionComment nvarchar(400)
AS
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT INTO UrlRewrite (
		UrlRewriteId,
		SiteName,
		SystemName,
		ExternalId,
		LatestRevisionNumber,
		Url,
		CreateDate,
		CreateMembershipId)
	VALUES (
		@UrlRewriteId,
		@SiteName,
		@SystemName,
		@ExternalId,
		1,
		@Url,
		@RevisionDate,
		@RevisionMembershipId)

	INSERT INTO UrlRewriteRevision (
		UrlRewriteId,
		RevisionNumber,
		StartDate,
		EndDate,
		IsSecure,
		RewriteOrder,
		IgnoreQueryString,
		PassQueryString,
		SiteUrlId,
		RevisionComment,
		RevisionDate,
		RevisionMembershipId)
	VALUES (
		@UrlRewriteId,
		1,
		@StartDate,
		@EndDate,
		@IsSecure,
		@RewriteOrder,
		@IgnoreQueryString,
		@PassQueryString,
		@SiteUrlId,
		@RevisionComment,
		@RevisionDate,
		@RevisionMembershipId)

	SELECT 1 as LatestRevisionNumber